#include "dev.h"
#include "gpio.h"
#include "kernel.h"
#include "iodev.h"
#include <string.h>
#include "ioctl.h"
#include "regs.h"
#include "config.h"


 int mylcd_init(iodev_t * dev)
{
		 dev_inf_t * dinf = iodev_get_inf(dev);
		 if (dinf == NULL) return -1;
 
		 lcd_inf_t * inf = (lcd_inf_t *)dinf->priv;
		 spi_slave_t * spi = &(inf->inf.spi_lcd.spi);
		 int i = 0;
		 uint8_t cmd;
		 spi_param_t param;

		 param.baud = 5000000; /* max clock */
		 param.bus_16bit = 0;
		 param.cpha = 1;
		 param.cpol = 1;
		 param.lsb_mod = 0;
		 
		 spi_register_slave(spi, &param);
 
	//	 if (inf->backlight_ctl) inf->backlight_ctl(1); /* Backlight ON */
 
	//	 gpio_output(inf->inf.spi_lcd.GPIO_A0, 0); /* Command Mode */
 
		 spi_xfer(spi, NULL, 0, NULL, SPI_XFER_BEGIN);
 
	//	 while ((cmd = lcd_init_cmd[i ++])) {
	//			 if (cmd == 0xFF) mdelay(lcd_init_cmd[i ++]); /* Delay Required */
	//			 else spi_xfer(spi, &cmd, 1, NULL, 0);
//		 }
		 spi_xfer(spi, NULL, 0, NULL, SPI_XFER_END);
	//	 memset(lcd_fb,0x00, LCD_BUF_LEN);
	//	  lcd_inf = inf;
		 return 0;
 }

